<template>
    <div class="View">
        <!-- tab切换菜单 -->
        <el-tabs v-model="activeName" class="bh-tab" @tab-click="handleClick" :before-leave="beforeLeaveFn">
            <el-tab-pane label="肉厚測定結果一覧" name="first"> </el-tab-pane>
            <el-tab-pane label="各設定状況" name="second"> </el-tab-pane>
            <el-tab-pane label="取替時対応" name="third"> </el-tab-pane>
        </el-tabs>
        <div class="all-content-warrper">
            <div class="title-view" v-if="activeName == 'first'">
                <div class="left">
                    <el-date-picker v-model="InspPeriodData.inspFrom" :format="format" :value-format="format"
                        style="width: 144px !important;" placeholder=" " :class="AData.length == 0 ? 'orange' : 'gray'"
                        :disabled="AData.length != 0 ||
                            (AData.length != 0 && (g_approval == 1 || g_approval == 0))"
                        :picker-options="pickerOptions">
                    </el-date-picker>
                    <span style="margin: 0 10px;">~</span>
                    <el-date-picker v-model="InspPeriodData.inspTo" :format="format" :value-format="format"
                        style="width: 144px !important;" placeholder=" " :class="AData.length == 0 ? 'orange' : 'gray'"
                        :disabled="AData.length != 0 ||
                            (AData.length != 0 && (g_approval == 1 || g_approval == 0))"
                        :picker-options="pickerOptions">
                    </el-date-picker>
                    <el-button style="margin-left: 24px;" type="primary" size="mini"
                        @click="getListComboxApi(0, true), g_Type = 0"
                        :disabled="(AData.length != 0 ||
                            (AData.length != 0 && (g_approval == 1 || g_approval == 0)) || (!InspPeriodData.inspFrom || !InspPeriodData.inspTo)) || AFlg">最新データ取込</el-button>
                </div>
                <div class="right">
                    <el-button style="margin-right: 24px;" type="primary" size="mini" :disabled="AData.length == 0"
                        @click="pushCAD">図面表示</el-button>
                    <span style="margin-right: 12px;min-width: 84px;">過去承認参照</span>
                    <el-select v-model="ApprovlComboxItem" :placeholder="$t('message.bhView.label.placeholderSearch')"
                        class="form-ipt" @change="ApprovlComboxChangeFn">
                        <el-option v-for="item in ApprovlCombox" :key="item.key" :label="item.item"
                            :value="item.key"></el-option>
                    </el-select>
                    <el-button style="margin-left: 24px;" size="mini" :disabled="AFlg"
                        @click="getListComboxApi(1), g_Type = 1">参照</el-button>
                </div>
            </div>
            <div class="title-view" v-if="activeName == 'second'">
                <div class="left">
                    <el-date-picker v-model="PeriodFrom" style="width: 144px !important;" :format="format"
                        :value-format="format" placeholder=" " class="orange">
                    </el-date-picker>
                    <span style="margin: 0 10px;">~</span>
                    <span>現在</span>
                    <el-button style="margin-left: 24px;" type="primary" size="mini" :disabled="!PeriodFrom || BFlg"
                        @click="GetVariousSetListApi">最新データ取込</el-button>
                </div>

            </div>
            <div class="title-view" v-if="activeName == 'third'">
                <div class="left">
                    <el-date-picker v-model="PeriodFrom" style="width: 144px !important;" :format="format"
                        :value-format="format" placeholder=" " class="orange">
                    </el-date-picker>
                    <span style="margin: 0 10px;">~</span>
                    <span>現在</span>
                    <el-button style="margin-left: 24px;" type="primary" size="mini" :disabled="!PeriodFrom || CFlg"
                        @click="GetReplacementListApi">最新データ取込</el-button>
                </div>
                <div class="right" style="width: 90px;" v-if="activeName == 'third'">
                    <el-button style="margin-right: 24px;" type="primary" size="mini" @click="pushCAD"
                        :disabled="CData.length == 0">図面表示</el-button>
                </div>
            </div>

            <div class="warp">
                <div class="tips" v-if="activeName == 'first'">
                    <div class="b-input-label">
                        {{ $t("message.bhView.label.Plant") }}
                    </div>
                    <el-select v-model="valuePlant" :placeholder="$t('message.bhView.label.placeholderSearch')"
                        class="form-ipt" @change="getApprovlComboxApi">
                        <el-option v-for="item in plantOptions" :key="item.pltCode" :label="item.pltName"
                            :value="item.pltCode"></el-option>
                    </el-select>

                    <el-button style="margin-left: 24px;" type="primary" size="mini" :disabled="AData.length == 0 ||
                        g_approval == 1" @click="getResetMsgApi">リセット</el-button>
                    <el-button style="margin-left: 24px;" type="primary" size="mini" :disabled="AData.length == 0 ||
                        g_approval == 1" @click="GetApprovalMsgApi">承認</el-button>
                    <el-button style="margin-left: 24px;" :type="!isDialog2Active2 ? 'primary' : ''" size="mini"
                        @click="showRetrievalBtn2" :style="{
                            background: isDialog2Active2 ? '#bc000f' : '', color: isDialog2Active2 ? '#fff' : '',
                            borderColor: isDialog2Active2 ? '#bc000f' : ''
                        }" :disabled="AData.length == 0 && !isDialog2Active2">抽出条件設定</el-button>
                    <el-button style="margin-left: 24px;" type="defalut" size="mini"
                        :disabled="AData.length == 0 && !isDialog2Active2" @click="clearEXFn">Clear</el-button>
                    <div class="report" style="margin-left: 15px;display: flex;">
                        <el-button :type="activeFlag == index ? 'primary' : ''" size="mini" :disabled="(AData.length == 0 && index == 0) || (ExportDagaJson.ApprovlComboxItem != 0
                            && index == 1) || AFlg" v-for="(value, index) in tabs_list" :key="index"
                            @click="handleButtonClick('first', index)"
                            style="width: auto;height: 24px;line-height: 0;margin: 0;">
                            {{ value.title }}
                        </el-button>
                    </div>
                </div>
                <div class="tips1" v-if="activeName == 'second' || activeName == 'third'">
                    <div style="display: flex;">
                        <div class="b-input-label">
                            {{ $t("message.bhView.label.Plant") }}
                        </div>
                        <el-input class="form-ipt yellow" :value="$store.state.plantName"></el-input>
                    </div>

                    <el-button type="primary" size="mini" :disabled="BData.length == 0" v-show="activeName == 'second'"
                        @click="handleButtonClick('second')" style="width: auto;height: 24px;float: right;">
                        Excel に エクスポート
                    </el-button>

                    <el-button type="primary" size="mini" :disabled="CData.length == 0" v-show="activeName == 'third'"
                        @click="handleButtonClick('third')" style="width: auto;height: 24px;float: right;">
                        Excel に エクスポート
                    </el-button>
                </div>

                <div class="table-view">
                    <AContentTable ref="AContentTableRef" :tableHeight="tableHeight" :AData="AData" @getCRow="getCRow"
                        :AListCombox=AListCombox :loading="loading" @getMSTabelRow="getMSTabelRow" :pageDes="pageDes"
                        @GetLineIndexListApi="GetLineIndexListApi" @changeFn="changeFn" v-show="activeName == 'first'"
                        :AFlg=AFlg>
                    </AContentTable>
                    <BContentTable ref="BContentTableRef" :tableHeight="tableHeight" :BData="BData" :loading="loading"
                        @getMSTabelRow="getMSTabelRow" :pageDes="pageDes" @GetVariousSetListApi1="GetVariousSetListApi1"
                        v-show="activeName == 'second'" :BFlg=BFlg>
                    </BContentTable>
                    <CContentTable ref="CContentTableRef" :tableHeight="tableHeight" :CData="CData" :loading="loading"
                        @getCRow="getCRow" :pageDes="pageDes" @GetLineIndexListApi="GetLineIndexListApi"
                        @changeFn="changeFn" v-show="activeName == 'third'" :CFlg=CFlg>
                    </CContentTable>
                </div>

                <div class="bottomView">
                    <!-- <p v-if="activeName == 'second'">{{ `件数 = ${BDataLen} / ${BDataCloneLen} 件` }}</p> -->

                    <div v-if="activeName == 'first'" style="display: flex;align-items: center;">
                        <el-button size="mini" @click="CancelFn" :disabled="AData.length == 0 ||
                            (AData.length != 0 && g_approval != 0)">Cancel</el-button>
                        <el-button style="margin-left: 24px;" type="primary" size="mini" :disabled="AData.length == 0 ||
                            (AData.length != 0 && g_approval != 0)" @click="OKFn(true)">編集内容を保存</el-button>
                        <p style="padding-left: 20px;">{{ `件数 = ${AtableTip} 件` }}</p>
                    </div>
                    <p v-if="activeName == 'second'">{{ `件数 = ${BDataLen} 件` }}</p>
                    <div v-if="activeName == 'third'" style="display: flex;align-items: center;">
                        <el-button size="mini" @click="CancelFn">Cancel</el-button>
                        <el-button style="margin-left: 24px;" type="primary" size="mini"
                            @click="OKFn(true)">編集内容を保存</el-button>
                        <p style="padding-left: 20px;">{{ `件数 = ${CData.length} 件` }}</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 111 -->
        <Dialog1 ref="Dialog1Ref" v-if="activeName == 'first' && export_dialog_flag && title == '配管肉厚測定結果一覧'"
            title='配管肉厚測定結果一覧' @CloseExprotDiloag="export_dialog_flag = false" :PeriodFrom="InspPeriodData.inspFrom"
            :inspTo="InspPeriodData.inspTo" :ApprovlComboxItem="ApprovlCombox[ApprovlComboxItem].item"
            :PltCode="valuePlant" :g_Type="g_Type" :ExportDagaJson="ExportDagaJson"></Dialog1>

        <ViewImportDialog ref="ViewImportDialogRef"
            v-if="activeName == 'first' && export_dialog_flag && title == 'Excelのインポート（配管肉厚測定結果一覧）'"
            title='Excelのインポート（配管肉厚測定結果一覧）' @CloseExprotDiloag="export_dialog_flag = false"
            :PeriodFrom="InspPeriodData.inspFrom" :inspTo="InspPeriodData.inspTo"
            :ApprovlComboxItem="ApprovlCombox[ApprovlComboxItem].item" :PltCode="valuePlant"
            @resetATableFn="resetATableFn"></ViewImportDialog>

        <!-- 222 -->
        <Dialog2 ref="Dialog2Ref" class="plan-c2" @showRetrievalBtn2="showRetrievalBtn2" @resetATableFn="resetATableFn"
            @isDialog2ActiveFn2="isDialog2ActiveFn2"></Dialog2>

        <Dialog3 ref="Dialog3Ref" v-if="activeName == 'second' && export_dialog_flag && title == '配管各設定状況'"
            title='配管各設定状況' @CloseExprotDiloag="export_dialog_flag = false" :PeriodFrom="PeriodFrom" :DataList="BData"
            :PltCode="valuePlant"></Dialog3>

        <Dialog4 ref="Dialog4Ref" v-if="activeName == 'third' && export_dialog_flag && title == '配管取替時対応'"
            title='配管取替時対応' @CloseExprotDiloag="export_dialog_flag = false" :PeriodFrom="PeriodFrom" :DataList="CData"
            :PltCode="valuePlant"></Dialog4>

        <!-- 333 -->
        <!-- <EnDialog v-if="'tab3' == isShowTab" @CloseTerm="isShowTab = null" :MacCode="tableSelectRow.mac_code"
            :Code="null" footer="footer2">
        </EnDialog> -->

        <!-- 444 -->
        <!-- <Dialog4 v-if="'tab4' == isShowTab" @CloseTerm="isShowTab = null" :MacCode="tableSelectRow.mac_code">
        </Dialog4> -->
    </div>
</template>

<script>
import { getPlant, GetLineIndexList } from "@/api/api";
import {
    getApprovlCombox, getInspPeriod, getListCombox, getThickJudgResList,
    getResetMsg, execReset, GetApprovalMsg, DataApproval,
    GetSaveApprovalMsg, SaveApproval, ClearApprovalUserCodSource,

    GetPeriodFrom, GetReplacementList, GetCancelMsg, GetSaveReplacementMsg, SaveReplacement,

    GetVariousSetList, DataAcquisition
} from "@/api/api1";
import {
    getClearMsg, getSvgByFun
} from "@/api/api";
import $ from "jquery";
import eventBus from "@/eventBus/bus";
import { getLocalStorage } from "@/utils/storage";
import AContentTable from './AContentTable';
import BContentTable from './BContentTable';
import CContentTable from './CContentTable';
import Dialog1 from './btnDialog/Dialog1';
import ViewImportDialog from './btnDialog/ViewImportDialog';
import Dialog2 from './btnDialog/Dialog2';
import Dialog3 from './btnDialog/Dialog3';
import Dialog4 from './btnDialog/Dialog4';
// import EnDialog from "@/components/Customize/Customer003/views/PipingManagement/btnDialog/EnDialog.vue"
// import Dialog4 from "@/components/Customize/Customer003/views/PipingManagement/btnDialog/Dialog4.vue"

import { showLoading, hideLoading } from "@/utils/loading";
import _ from 'lodash-es';

// 导出模块
export default {
    // 模块名字
    name: "PipingManagement",
    // 注册组件
    components: {
        AContentTable, BContentTable, CContentTable, Dialog1, ViewImportDialog, Dialog2, Dialog3, Dialog4
    },
    // 模块数据
    data() {
        //数据
        return {
            AFlg: false,
            BFlg: false,
            CFlg: false,
            isNavLeave: false,
            userData: getLocalStorage('userData'),
            activeName: "first",

            valuePlant: "",
            tempValuePlant: "",
            plantOptions: [],
            changePlantFlg: false,

            tableHeight: 278,
            prposTabelData: [],
            loading: false,
            tableSelectRow: {
                lineNo: '',
                mac_code: 0
            },

            showRetrievalFlg1: false,
            showRetrievalFlg2: false,

            isDialog2Active2: false,
            isShowTab: '',


            format: 'yyyy-MM-dd',
            activeFlag: 0,
            title: '',
            export_dialog_flag: false,
            tabs_list: [
                { title: "Excel に エクスポート", },
                { title: "Excel から インポート", },
            ],
            /**
             *  TAB1
             *  获取承认数据
             *  最新取入日期
             *  获取列表中的下拉框
             *  获取列表数据
             */
            AtableTip: "",
            pickerOptions: {
                disabledDate(time) {
                    // console.log('time.getTime()', time.getTime());
                    return time.getTime() < new Date('1900-1-1').getTime() || time.getTime() > new Date('2099-12-31').getTime();
                }
            },
            ExportDagaJson: {
                AprIspFrom: '',
                AprIspTo: '',
                ApprovlComboxItem: 0
            },

            ApprovlCombox: [],
            ApprovlComboxItem: 0,

            InspPeriodData: {
                inspFrom: '',
                inspTo: '',
            },

            AListCombox: {},

            AData: [],
            Crow: {},

            g_approval: -1,
            BDataCloneLen: '',
            BDataLen: '',
            /**
             *  TAB3
             *  期間(from)
             *  最新取入日期
             *  获取列表中的下拉框
             *  获取列表数据
             */
            PeriodFrom: '',
            CData: [],

            BData: [],
            pageDes: '',

            g_Type: 0,

            // isChange: false
        };
    },

    computed: {},


    // 监听指定值，只有指定值变化，才会触发
    watch: {
        activeName: {
            immediate: true,
            handler(nData) {
                console.log('activeName', nData);
                if (nData == 'first') {
                    this.activeFlag = 0;
                    this.getPlantApi(1, 1000, true);
                    this.$refs.AContentTableRef.refreshColumnFn();

                    // setTimeout(() => {
                    //     this.getListComboxApi();
                    // }, 500);
                }
                if (nData == 'second') {
                    //
                    this.GetPeriodFromApiTab2();
                    this.$refs.BContentTableRef.refreshColumnFn();
                }
                if (nData == 'third') {
                    this.GetPeriodFromApiTab2();
                    this.$refs.CContentTableRef.refreshColumnFn();
                }
            },
        },
        isDialog2Active2: {
            immediate: true,
            handler(nData) {
                console.log('isDialog2Active2', nData);
            },
        },
    },
    // 里面的函数只有调用才会执行（实时计算）里面是定义的方法
    methods: {
        /**
         * 重置 过去承认选择第一项(上一次)，加载上次加载成功的数据即可
         */
        async resetATableFn(e) {

            if (e == 'resetApprovlCombox') {
                this.getApprovlComboxApi(true);
                return
            }

            this.ApprovlComboxItem = this.ExportDagaJson.ApprovlComboxItem

            showLoading();
            this.g_approval = -1;
            this.AData = [];
            // let dataJson = {
            //     PltCode: Number(this.valuePlant),
            //     AprIspFrom: type == 1 ? this.ApprovlCombox[this.ApprovlComboxItem].aprIspFrom : this.InspPeriodData.inspFrom,
            //     AprIspTo: type == 1 ? this.ApprovlCombox[this.ApprovlComboxItem].aprIspTo : this.InspPeriodData.inspTo,
            //     ApprovlTxt: this.ApprovlCombox[this.ApprovlComboxItem].item,
            // };
            // this.ExportDagaJson = dataJson;
            this.AtableTip = '';
            let res = await getThickJudgResList(this.ExportDagaJson);
            hideLoading();
            console.log('getThickJudgResListApi', res);
            this.AtableTip = res.data.msg;
            if (res.data.code != 0) {
                return
            }

            // if (type != 1) {
            //     setTimeout(() => {
            //         this.getApprovlComboxApi();
            //     }, 1000);
            // }
            this.AData = res.data.data;
            this.AData.forEach((item, index) => {
                item._index = index;
            })

            this.g_approval = this.AData[0].approval;
            setTimeout(() => {
                // if (this.isDialog2Active2) {
                this.$refs.AContentTableRef.setCurrentRowFn(0);
                this.Crow = this.AData[0];
                // }
            }, 500);
        },

        //Report
        handleButtonClick(type, index) {
            if (type == 'first') {
                this.activeFlag = index;
                if (index == 0) {
                    this.export_dialog_flag = true;
                    this.title = '配管肉厚測定結果一覧';
                }
                if (index == 1) {
                    this.export_dialog_flag = true;
                    this.title = 'Excelのインポート（配管肉厚測定結果一覧）';
                }
            }

            if (type == 'second') {
                this.export_dialog_flag = true;
                this.title = '配管各設定状況';
            }

            if (type == 'third') {
                this.export_dialog_flag = true;
                this.title = '配管取替時対応';
            }

            // let Fn = () => {
            //     this.activeFlag = index;
            //     if (index === 0) {
            //         this.title = "系統情報";
            //         this.export_dialog_flag = true;
            //     } else if (index === 1) {
            //         this.title = "系統情報";
            //         this.import_dialog_flag = true;
            //     }
            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // if (this.$store.state.isCurrentNext) {
            //     Fn();
            // } else {
            //     /**
            //       * 4-1。   记录原来该运行的函数。
            //       * 4-2。   执行保存弹出框操作。   
            //       */

            //     this.$store.commit("changeIsCurrentFn", Fn);

            //     this.isCurrentNenxtFn(Fn);
            // }

        },
        //  菜单切换
        beforeLeaveFn(activeName, oldActiveName) {
            return this.isNavLeave
        },
        handleClick(tab, event) {
            let Fn = () => {
                this.isNavLeave = true;
                this.activeName = tab.name;
                if (
                    this.activeName == "first" || this.activeName == "third"
                ) {
                    setTimeout(() => {
                        this.isNavLeave = false;
                    }, 500);

                    return;
                }
                // if (
                //     this.activeName != "fourth"
                // ) {
                //     setTimeout(() => {
                //         this.isNavLeave = false;
                //     }, 500);

                //     return;
                // }
            }
            /**
             * 2。  记录当前函数。
             */
            if (this.$store.state.isCurrentNext) {
                Fn();
            } else {
                /**
                  * 4-1。   记录原来该运行的函数。
                  * 4-2。   执行保存弹出框操作。   
                  */

                this.$store.commit("changeIsCurrentFn", Fn);

                this.isCurrentNenxtFn(Fn);
            }

        },
        //  数据是否更改
        changeFn(e) {
            console.log(e);
            this.$store.state.isCurrentNext = e;
        },
        CancelFn() {
            if (this.activeName == 'first') {
                // this.getThickJudgResListApi();
                this.resetATableFn();
            }
            if (this.activeName == 'second') {
                //
                // this.GetVariousSetListApi();
            }
            if (this.activeName == 'third') {
                this.GetCancelMsgFn();
            }
        },
        OKFn(isBtn = false) {
            if (this.activeName == 'first') {
                this.saveFn1(isBtn);
            }
            if (this.activeName == 'second') {
                //
            }
            if (this.activeName == 'third') {
                this.saveFn3(isBtn);
            }
        },
        /**
         * Start    TAB1
         */
        //  获取装置
        getPlantApi(pageIndex, pageSize, isStart = false) {
            this.AData = [];

            let dataJson = {
                pltCode: 0,
                platName: "",
                pageIndex: pageIndex,
                pageSize: pageSize,
            };
            getPlant(dataJson).then((res) => {
                this.plantOptions = [];
                if (res.data.code != 0) {
                    return;
                }
                this.plantOptions = res.data.data;

                let filterFlg = this.plantOptions.filter(item => item.pltCode == this.$store.state.pltCode);
                //  如果有选择过装置 ---添加为记忆选项

                if (this.$store.state.pltCode && filterFlg.length > 0) {
                    this.valuePlant = this.$store.state.pltCode;
                } else {
                    this.valuePlant = this.plantOptions[0].pltCode;
                    this.$store.commit("changePltCode", this.valuePlant);
                }
                // 更新保存的装置name
                this.plantOptions.forEach((Item) => {
                    if (Item.pltCode == this.valuePlant) {
                        let valuePlant = Item.pltName;
                        this.$store.commit("changePlantName", valuePlant);
                    }
                });
                this.getApprovlComboxApi(isStart);
            });
        },

        //  获取 承认 下拉框
        async getApprovlComboxApi(isStart) {
            console.log('isStart', isStart);

            this.tempValuePlant = this.valuePlant;

            let Fn = async () => {

                // this.AData = [];

                // 更新保存的装置name
                this.$store.commit("changePltCode", this.valuePlant);
                this.plantOptions.forEach((Item) => {
                    if (Item.pltCode == this.valuePlant) {
                        let valuePlant = Item.pltName;
                        this.$store.commit("changePlantName", valuePlant);
                    }
                });

                this.ApprovlCombox = [];
                this.ApprovlComboxItem = {};
                let dataJson = {
                    PltCode: Number(this.valuePlant),
                };
                // showLoading();
                let res = await getApprovlCombox(dataJson);
                // hideLoading();
                console.log('getApprovlComboxApi', res);
                if (res.data.code != 0) {
                    return
                }
                this.ApprovlCombox = res.data.data;
                this.ApprovlCombox.forEach((item, index) => {
                    item.key = index
                })
                this.ApprovlComboxItem = this.ApprovlCombox[0].key;
                // if (this.ApprovlCombox[0].aprIspFrom == '') {
                //     this.getInspPeriodApi();
                //     return
                // }
                this.InspPeriodData.inspFrom = this.ApprovlCombox[0].aprIspFrom;
                this.InspPeriodData.inspTo = this.ApprovlCombox[0].aprIspTo;
                if (isStart) {
                    this.InspPeriodData.inspFrom = this.ApprovlCombox[0].aprIspFrom;
                    this.InspPeriodData.inspTo = this.ApprovlCombox[0].aprIspTo;

                    setTimeout(() => {
                        this.getListComboxApi(1, true);
                    }, 500);
                }
            }
            /**
             * 2。  记录当前函数。
             */
            this.$store.commit("changeIsCurrentFn", Fn);

            this.isCurrentNenxtFn(Fn);

        },
        ApprovlComboxChangeFn(e) {
            // if (this.ApprovlCombox[e].aprIspFrom == '') {
            //     this.getInspPeriodApi();
            //     return
            // }
            // this.InspPeriodData.inspFrom = this.ApprovlCombox[e].aprIspFrom;
            // this.InspPeriodData.inspTo = this.ApprovlCombox[e].aprIspTo;

        },

        //  获取 检查期间 FROM-TO
        async getInspPeriodApi() {
            this.InspPeriodData = {};
            let dataJson = {
                PltCode: Number(this.valuePlant),
            };
            let res = await getInspPeriod(dataJson);
            console.log('getInspPeriodApi', res);
            if (res.data.code != 0) {
                return
            }
            this.InspPeriodData = res.data.data;

            // this.getListComboxApi();
        },

        //  获取 A 列表中的Combox   type-0 最新取入 type-1 参照
        async getListComboxApi(type = this.g_Type, isBtn = false) {
            this.AFlg = true;
            showLoading();
            if (type == 1) {
                this.InspPeriodData.inspFrom = this.ApprovlCombox[this.ApprovlComboxItem].aprIspFrom;
                this.InspPeriodData.inspTo = this.ApprovlCombox[this.ApprovlComboxItem].aprIspTo;
            }
            // let Fn = async () => {
            this.AListCombox = {};
            let dataJson = {};
            let res = await getListCombox(dataJson);
            hideLoading();
            console.log('getListComboxApi', res);
            if (res.data.code != 0) {
                return
            }
            this.AListCombox = res.data.data;

            if (type == 0 && isBtn) {
                this.DataAcquisitionApi(type);
            }
            if ((type == 0 && !isBtn) || type == 1) {
                this.getThickJudgResListApi(type);
            }
            // if (type == 1) {
            //     this.getThickJudgResListApi(type);
            // }
            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // this.$store.commit("changeIsCurrentFn", Fn);

            // this.isCurrentNenxtFn(Fn);
        },

        //  获取 A 肉厚测定结果一览列表--参照
        async getThickJudgResListApi(type) {
            this.$store.state.isCurrentNext = true;
            showLoading();
            this.g_approval = -1;
            this.AData = [];
            let dataJson = {
                PltCode: Number(this.valuePlant),
                AprIspFrom: type == 1 ? this.ApprovlCombox[this.ApprovlComboxItem].aprIspFrom : this.InspPeriodData.inspFrom,
                AprIspTo: type == 1 ? this.ApprovlCombox[this.ApprovlComboxItem].aprIspTo : this.InspPeriodData.inspTo,
                ApprovlTxt: this.ApprovlCombox[this.ApprovlComboxItem].item,
                ApprovlComboxItem: this.ApprovlComboxItem
            };
            this.ExportDagaJson = dataJson;
            this.AtableTip = '';
            let res = await getThickJudgResList(dataJson);
            hideLoading();
            this.AFlg = false;

            this.AtableTip = res.data.msg;

            console.log('getThickJudgResListApi', res);
            if (res.data.code != 0) {
                return
            }
            if (type != 1) {
                setTimeout(() => {
                    this.getApprovlComboxApi();
                }, 1000);
            }
            this.AData = res.data.data;
            this.AData.forEach((item, index) => {
                item._index = index;
            })

            this.g_approval = this.AData[0].approval;
            setTimeout(() => {
                // if (this.isDialog2Active2) {
                this.$refs.AContentTableRef.setCurrentRowFn(0);
                this.Crow = this.AData[0];
                // }
            }, 500);

        },

        //  最新取入
        async DataAcquisitionApi(type) {
            // showLoading();
            this.g_approval = -1;
            this.AData = [];
            let dataJson = {
                PltCode: Number(this.valuePlant),
                AprIspFrom: this.InspPeriodData.inspFrom,
                AprIspTo: this.InspPeriodData.inspTo,
            };
            let res = await DataAcquisition(dataJson);
            // hideLoading();
            // setTimeout(() => {
            //     this.getApprovlComboxApi();
            // }, 1000);

            if (!res || res.data.code != 0) {
                this.AFlg = false;
                return
            }
            this.getThickJudgResListApi(type);
            hideLoading();
            // console.log('DataAcquisitionApi', res);
            // if (res.data.code != 0 || Object.keys(res.data.data).length == 0) {
            //     return
            // }
            // this.AData = res.data.data;
            // this.AData.forEach((item, index) => {
            //     item._index = index;
            // })

            // this.g_approval = this.AData[0].approval;
        },

        //  リセット(クリック) reset，在未承认时点击提示信息
        async getResetMsgApi() {
            let Fn = async () => {
                let dataJson = {};
                showLoading();
                let res = await getResetMsg(dataJson);
                hideLoading();
                if (res.data.code == 451) {

                    let m = res.data.msg.replace(/\r/g, '<br/>');

                    this.$confirm(m, '', {
                        confirmButtonText: 'OK',
                        cancelButtonText: 'Cancel',
                        type: 'warning',
                        dangerouslyUseHTMLString: true,
                    }).then(async () => {
                        //  リセット(クリック) reset
                        let dataJson = {
                            PltCode: Number(this.valuePlant),
                        };
                        let res = await execReset(dataJson);
                        if (res.data.code != 0) {
                            this.$alert(res.data.msg, '', {
                                confirmButtonText: 'OK',
                                type: 'warning',
                            });
                            return
                        }
                        this.$message.success(res.data.msg);
                        // this.getThickJudgResListApi();
                        this.resetATableFn();
                    }).catch(() => {

                    });
                }
            }
            /**
             * 2。  记录当前函数。
             */
            this.$store.commit("changeIsCurrentFn", Fn);

            this.isCurrentNenxtFn(Fn);

        },

        //  承認(クリック) 确认提示信息
        async GetApprovalMsgApi() {

            let Fn = async () => {
                showLoading();
                let dataJson = {
                    PltCode: Number(this.valuePlant),
                };
                let res = await GetApprovalMsg(dataJson);
                hideLoading();
                if (res.data.code == 451) {
                    let m = res.data.msg.replace(/\r/g, '<br/>');

                    this.$confirm(m, '', {
                        confirmButtonText: 'OK',
                        cancelButtonText: 'Cancel',
                        type: 'warning',
                        dangerouslyUseHTMLString: true,
                    }).then(async () => {
                        showLoading();
                        // 承認(クリック)
                        let dataJson = {
                            PltCode: Number(this.valuePlant),
                            AprIspFrom: this.InspPeriodData.inspFrom,
                            AprIspTo: this.InspPeriodData.inspTo,
                            DataList: this.AData,
                        };
                        let res = await DataApproval(dataJson);
                        hideLoading();
                        if (res.data.code != 0) {
                            this.$alert(res.data.msg, '', {
                                confirmButtonText: 'OK',
                                type: 'warning',
                            });
                            return
                        }
                        this.$message.success(res.data.msg);
                        this.getApprovlComboxApi();
                        this.AData = [];
                        // this.getThickJudgResListApi();
                        this.getListComboxApi();
                    }).catch(() => {

                    });
                }

            }
            /**
             * 2。  记录当前函数。
             */
            this.$store.commit("changeIsCurrentFn", Fn);

            this.isCurrentNenxtFn(Fn);

        },

        //  編集内容を保存(クリック) 前 消息提示
        async saveFn1(isBtn = false) {
            showLoading();
            let dataJson = {
                DataList: this.AData,
            };
            let res = await GetSaveApprovalMsg(dataJson);
            hideLoading();
            if (res.data.code != 451) {
                this.$store.state.isCurrentNext = true;
                return
            }

            let m = res.data.msg.replace(/\r/g, '<br/>');

            this.$confirm(m, '', {
                confirmButtonText: 'OK',
                cancelButtonText: 'Cancel',
                type: 'warning',
                dangerouslyUseHTMLString: true,

            }).then(async () => {
                //  編集内容を保存(クリック)
                let dataJson = {
                    DataList: this.AData,
                    PltCode: Number(this.valuePlant),
                    IspFrom: this.InspPeriodData.inspFrom,
                    IspTo: this.InspPeriodData.inspTo,
                };
                console.log('saveFn', dataJson);
                let res = await SaveApproval(dataJson);
                if (res.data.code != 0) {
                    this.chenOldParams();
                    let m = res.data.msg.replace(/\r/g, '<br/>');
                    this.$alert(m, '', {
                        confirmButtonText: 'OK',
                        type: 'warning',
                        dangerouslyUseHTMLString: true
                    });
                    setTimeout(() => {
                        this.$refs.AContentTableRef.setCurrentRowFn(res.data.data);
                    }, 300);
                    return
                }

                this.$message.success(res.data.msg);
                if (isBtn) {
                    // this.getThickJudgResListApi();
                    this.resetATableFn();
                } else {
                    this.$store.state.isCurrentFn();
                }
                this.$store.commit("reSetIsCurrent");
            }).catch(() => {
                if (isBtn) {
                    // this.$store.commit("reSetIsCurrent");
                    return
                }
                this.$store.state.isCurrentFn();
                this.$store.commit("reSetIsCurrent");
            });

        },

        //  Clear 抽出条件设定
        async clearEXFn() {

            // let Fn = async () => {
            let dataJson = {};
            showLoading();
            let res = await getClearMsg(dataJson);
            hideLoading();
            if (res.data.code == 451) {
                this.$confirm(res.data.msg, '', {
                    confirmButtonText: 'OK',
                    cancelButtonText: 'Cancel',
                    type: 'warning'
                }).then(async () => {
                    //  Clear 抽出条件设定
                    let dataJson = {};
                    console.log('clearEXFn', dataJson);
                    let res = await ClearApprovalUserCodSource(dataJson);
                    if (res.data.code != 0) {
                        this.$alert(res.data.msg, '', {
                            confirmButtonText: 'OK',
                            type: 'warning',
                        });
                        return
                    }
                    this.isDialog2ActiveFn2(false);
                    this.$message.success(res.data.msg);
                    this.showRetrievalBtn2('hidden');
                    // this.getThickJudgResListApi();
                    this.resetATableFn();
                }).catch(() => {

                });
            }
            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // this.$store.commit("changeIsCurrentFn", Fn);

            // this.isCurrentNenxtFn(Fn);
        },

        /**
         * Start    TAB2
         */

        //  取替時対応-获取 取替時対応数据列表
        async GetPeriodFromApiTab2() {
            let dataJson = {};
            let res = await GetPeriodFrom(dataJson);
            console.log('GetPeriodFromApiTab2', res);
            if (res.data.code != 0) {
                return
            }
            this.PeriodFrom = res.data.data;
            this.BData = [];
            this.BDataLen = 0;
            this.BDataCloneLen = 0;
            this.BDataClone = [];
            this.CData = [];
        },
        async GetVariousSetListApi() {
            this.$refs.BContentTableRef.refreshColumnFn();
            this.BFlg = true;
            showLoading();
            this.pageDes = '';
            this.BData = [];
            let dataJson = {
                PltCode: Number(this.valuePlant),
                PeriodFrom: this.PeriodFrom
            };
            let res = await GetVariousSetList(dataJson);
            this.BFlg = false;
            hideLoading();
            console.log('GetVariousSetListApi', res);
            if (res.data.code != 0) {
                return
            }
            this.pageDes = res.data.data.cntLab;
            this.BData = res.data.data.dataList;
            this.BData.forEach((item, index) => {
                item._index = index;
            })
            this.BDataClone = _.cloneDeep(this.BData);
            this.BDataLen = this.BDataClone.length;
            this.BDataCloneLen = this.BDataClone.length;
        },
        //  自定义筛选条件
        GetVariousSetListApi1(e) {
            showLoading();
            console.log(e, 'GetVariousSetListApi1');
            let tempValue = e.map((item, index) => {
                return {
                    key: `st${index + 1}Name`,
                    value: item
                }
            })

            let tempArr = tempValue.filter(item => item.value == 'NO').map(item => item.key)

            if (tempArr.length > 0) {
                this.BData = this.BDataClone.filter(obj => {
                    return tempArr.every(propName => obj.hasOwnProperty(propName) && obj[propName] === 'NO');
                });
            }
            if (tempArr.length == 0) {
                this.BData = this.BDataClone;
            }
            this.BDataLen = this.BData.length;
            this.BDataCloneLen = this.BDataClone.length;
            hideLoading();
        },


        /**
         * Start    TAB3
         */
        // 跳转
        getCRow(row) {
            this.Crow = row
        },
        async pushCAD() {

            // let Fn = async () => {
            let D = { dmgCode: this.Crow.dmgCode, pltCode: this.valuePlant, FunType: 7 };
            showLoading();
            let res = await getSvgByFun(D);
            hideLoading();
            if (!res || res.data.code != 0) {
                // this.$alert(res.data.msg, '', {
                //     confirmButtonText: 'OK',
                //     type: 'warning',
                // });
                return;
            }

            var { href } = this.$router.resolve({
                name: "CAD",
                query: {
                    id: res.data.data[0].id,
                    radioType: -1
                },
            });

            let newWindow = window.open(href, "_blank");

            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // this.$store.commit("changeIsCurrentFn", Fn);

            // this.isCurrentNenxtFn(Fn);
        },
        isCurrentNenxtFn(Fn) {
            /**
              * 3。  isCurrentNext。true=>往下，正常运行原有函数。
              */
            if (this.$store.state.isCurrentNext) {
                Fn();
            } else {
                /**
                  * 4-1。   记录原来该运行的函数。
                  * 4-2。   执行保存弹出框操作。   
                  */

                this.OKFn();
            }
        },

        //  取替時対応->获取 期間(from)
        async GetPeriodFromApi() {
            let dataJson = {};
            let res = await GetPeriodFrom(dataJson);
            console.log('GetPeriodFromApi', res);
            if (res.data.code != 0) {
                return
            }
            this.PeriodFrom = res.data.data;

            this.GetReplacementListApi();
        },

        //  取替時対応-获取 取替時対応数据列表
        async GetReplacementListApi() {

            // let Fn = async () => {
            this.$store.state.isCurrentNext = true;
            this.CFlg = true;
            showLoading();
            this.CData = [];
            let dataJson = {
                PltCode: Number(this.valuePlant),
                PeriodFrom: this.PeriodFrom
            };
            let res = await GetReplacementList(dataJson);
            this.CFlg = false;
            hideLoading();
            console.log('GetReplacementListApi', res);
            if (res.data.code != 0) {
                return
            }
            this.CData = res.data.data;
            this.CData.forEach((item, index) => {
                item._idx = index;
            })
            //1111111111111111
            this.$refs.CContentTableRef.setCurrentRowFn(0);
            this.Crow = this.CData[0];
            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // this.$store.commit("changeIsCurrentFn", Fn);

            // this.isCurrentNenxtFn(Fn);
        },

        //  取替時対応->点击取消按钮Cancel(クリック) 提示信息
        async GetCancelMsgFn() {
            console.log(this.CData);

            let dataJson = {};
            let res = await GetCancelMsg(dataJson);
            if (res.data.code == 451) {
                this.$confirm(res.data.msg, '', {
                    confirmButtonText: 'OK',
                    cancelButtonText: 'Cancel',
                    type: 'warning'
                }).then(async () => {

                    this.GetReplacementListApi();
                }).catch(() => {

                });
            }
        },

        //  取替時対応->获取 編集内容を保存(クリック) 前提示信息
        async saveFn3(isBtn = false) {
            showLoading();
            let dataJson = {
                DataList: this.CData
            };
            let res = await GetSaveReplacementMsg(dataJson);
            hideLoading();
            if (res.data.code != 451) {
                this.$store.state.isCurrentNext = true;
                return
            }
            this.$confirm(res.data.msg, '', {
                confirmButtonText: 'OK',
                cancelButtonText: 'Cancel',
                type: 'warning'
            }).then(async () => {
                //  取替時対応->編集内容を保存(クリック)
                let dataJson = {
                    DataList: this.CData
                };
                console.log('saveFn3', dataJson);
                let res = await SaveReplacement(dataJson);
                if (res.data.code != 0) {
                    this.$alert(res.data.msg, '', {
                        confirmButtonText: 'OK',
                        type: 'warning',
                    });
                    return
                }

                this.$message.success(res.data.msg);
                if (isBtn) {
                    this.GetReplacementListApi();
                } else {
                    this.$store.state.isCurrentFn();
                    this.$store.commit("reSetIsCurrent");
                }
            }).catch(() => {
                if (isBtn) {
                    // this.$store.commit("reSetIsCurrent");
                    return
                }
                this.$store.state.isCurrentFn();
                this.$store.commit("reSetIsCurrent");
            });

        },


        /**
         * End
         */



        //右侧筛选

        isDialog2ActiveFn2(e) {
            this.isDialog2Active2 = e;
        },
        //右侧筛选
        showRetrievalBtn2(flg) {

            // let Fn = async () => {
            this.showRetrievalFlg1 = false;


            if (flg == 'hidden') {
                this.showRetrievalFlg2 = false;
                this.showRoHiddenRetrieva2(this.showRetrievalFlg2);
                return
            }
            this.showRetrievalFlg2 = !this.showRetrievalFlg2;
            this.showRoHiddenRetrieva2(this.showRetrievalFlg2);

            // }
            // this.$store.commit("changeIsCurrentFn", Fn);

            // if (this.$store.state.isCurrentNext) {
            //     Fn();
            // }
            // /**
            //  * 2。  记录当前函数。
            //  */
            // this.$store.commit("changeIsCurrentFn", Fn);

            // this.isCurrentNenxtFn(Fn);
        },
        showRoHiddenRetrieva2(flg) {
            if (flg) {
                $('.plan-c2').css('right', '10px');
                // 通知第一次显示
                this.$refs.Dialog2Ref.GetApprovalCodSourceApi();
            } else {
                $('.plan-c2').css('right', '-560px');
            }
        },

        //获取右上表格某一行数据
        getMSTabelRow(row) {
        },


        chenOldParams() {
            this.valuePlant = this.tempValuePlant;
        },
        refreshFn() {
        },
        // 获取数据
        async GetLineIndexListApi(name) {

        },
    },
    // 创建完毕状态(里面是操作)
    created() { },
    // 挂载结束状态(里面是操作)
    mounted() {
        (this.tableHeight = $(".View").height() - 200);

        // this.getPlantApi(1, 1000, true);


        // setTimeout(() => {
        //     this.$refs.AContentTableRef.refreshColumnFn();
        //     this.getListComboxApi();
        // }, 500);

        // this.getPlantApi(1, 1000);
        eventBus.$on('EventBusBasicStyleCompontensSaveFn', () => {
            this.OKFn();
        })
    },
    // 销毁前状态(里面是操作)
    beforeDestroy() {
        eventBus.$off('EventBusBasicStyleCompontensSaveFn');
    },
};
</script>
<style lang="scss" scoped>
.View {
    width: calc(100% - 215px);
    height: 100%;
    margin-left: 24px;

    .bh-tab {
        width: 100%;

        ::v-deep .el-tabs__header {
            margin: 14px 24px 0 0;
            width: calc(100% -48px);
        }

        ::v-deep .el-tabs__content {
            height: calc(100% - 55px);
        }

        ::v-deep #pane-first {
            height: 100%;
        }

        ::v-deep #pane-second {
            height: 100%;
        }

        ::v-deep #pane-third {
            height: 100%;
        }
    }

    .all-content-warrper {
        width: 100%;
        height: calc(100% - 55px);

        .title-view {
            width: calc(100% - 24px);
            background: #f8f8f8;
            border-bottom: 1px solid #e1e1e1;
            height: 48px;
            display: flex;
            justify-content: space-between;


            .left {
                display: flex;
                align-items: center;
                width: calc(100% - 1270px);

                ::v-deep .el-input__inner {
                    height: 24px;
                    color: rgba(0, 0, 0, 0.65);
                    background: #f8f8f8;
                    width: 144px !important;
                }

                ::v-deep .el-input__icon {
                    line-height: 24px;
                }
            }

            .right {
                display: flex;
                align-items: center;
                width: calc(100% - 1085px);

                ::v-deep .el-input__inner {
                    height: 24px;
                    color: rgba(0, 0, 0, 0.65);
                    background: #f8f8f8;
                    width: 300px;
                }

                ::v-deep .el-input__icon {
                    line-height: 24px;
                }
            }



            .el-button {
                height: 24px;
            }

        }
    }
}


::v-deep .el-button.is-disabled,
::v-deep .el-button.is-disabled:hover {
    background: #ebeef5 !important;
    color: #c0c4cc !important;
}

.orange {
    ::v-deep .el-input__inner {
        background-color: #FEDDB1 !important;
    }
}

.gray {
    ::v-deep .el-input__inner {
        background-color: rgb(235, 238, 245) !important;
    }
}

.yellow {
    ::v-deep .el-input__inner {
        background: #ffffe1 !important;
    }
}

.warp {
    height: 100%;
    width: calc(100% - 24px);

    .tips {
        padding-top: 16px;
        display: flex;
        align-items: center;
        margin-bottom: 16px;

        // justify-content: space-between;
        .b-input-label {
            display: flex;
            align-items: center;
        }

        .form-ipt {
            width: 210px;
            height: 24px;

            ::v-deep .el-input__inner {
                height: 24px;
                background: #fff;
            }

            ::v-deep .el-input__icon {
                line-height: 24px;
            }
        }

        .refresh {
            min-width: 40px;
            height: 24px;
            border-radius: 4px;
            border: 1px solid #d9d9d9;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;

            .iconfont {
                margin: 0 4px;
                font-size: 17px;
                height: 24px;
                line-height: 24px;
            }
        }

        .el-button {
            height: 24px;
            line-height: 10px;
            // border: none;
        }
    }

    .tips1 {
        padding-top: 16px;
        display: flex;
        align-items: center;
        margin-bottom: 16px;
        justify-content: space-between;

        .b-input-label {
            display: flex;
            align-items: center;
        }

        .form-ipt {
            width: 210px;
            height: 24px;

            ::v-deep .el-input__inner {
                height: 24px;
                background: #fff;
            }

            ::v-deep .el-input__icon {
                line-height: 24px;
            }
        }

        .refresh {
            min-width: 40px;
            height: 24px;
            border-radius: 4px;
            border: 1px solid #d9d9d9;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;

            .iconfont {
                margin: 0 4px;
                font-size: 17px;
                height: 24px;
                line-height: 24px;
            }
        }

        .el-button {
            height: 24px;
            line-height: 10px;
            // border: none;
        }
    }

    .table-view {
        width: 100%;
        height: calc(100% - 150px);
        // overflow: hidden;
    }
}

.plan-c1 {
    position: fixed;
    width: 560px !important;
    height: calc(100% - 198px);
    background: #FFF;
    right: -560px;
    bottom: 0;
    z-index: 9999;
    transition: all 0.3s ease;
    border: 1px solid #C3C3C3;
}

.plan-c2 {
    position: fixed;
    width: 560px !important;
    height: calc(100% - 198px);
    background: #FFF;
    right: -560px;
    bottom: 0;
    z-index: 9999;
    transition: all 0.3s ease;
    border: 1px solid #C3C3C3;
}

.bottomView {
    display: flex;
    align-items: center;
    height: 52px;

    button {
        height: 24px;
    }
}
</style>